package redis

import (
	"context"
	"fmt"
)

const StockGood = "cart:good_stock:good_id_"

func GoodStock(goodId, stock int64) {
	key := StockGood + fmt.Sprintf("%d", goodId)
	for i := 0; i < int(stock); i++ {
		Rdb.LPush(context.Background(), key, stock)
	}
}

func GetStock(goodId int64) int64 {
	key := StockGood + fmt.Sprintf("%d", goodId)
	return Rdb.LLen(context.Background(), key).Val()
}
